package com.yami.shop.im;

import com.yami.shop.im.socket.*;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;

/**
 * @author lgh
 */
@SpringBootApplication
@ComponentScan(basePackages = {"com.yami.shop"})
public class ImApplication extends SpringBootServletInitializer {

    public static void main(String[] args) {
        ConfigurableApplicationContext applicationContext = SpringApplication.run(ImApplication.class, args);
        UserWebSocketServer.setApplicationContext(applicationContext);
        ShopWebSocketServer.setApplicationContext(applicationContext);
        PlatformWebSocketServer.setApplicationContext(applicationContext);
        UserOnlineWebSocketServer.setApplicationContext(applicationContext);
        ShopOnlineWebSocketServer.setApplicationContext(applicationContext);
        PlatformOnlineWebSocketServer.setApplicationContext(applicationContext);
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(ImApplication.class);
    }

}
